//
//  AppLogoView.m
//  HuaRun2
//
//  Created by admin on 17/9/4.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "AppLogoView.h"

@implementation AppLogoView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
#pragma mark - life cycle
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self viewInit];
[self layoutInit];
}
return self;
}

- (void)viewInit {
//self.backgroundColor = kRandomColor;

[self addSubview:self.keyImageView];
[self addSubview:self.valueLab1];
[self addSubview:self.valueLab2];

}

- (void)layoutInit {
weakself(ws);

    [self.keyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws).offset(0);
        make.centerX.mas_equalTo(ws).offset(0);
//        make.size.mas_equalTo(CGSizeMake(55, 55));
    }];
    
    [self.valueLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws).offset(0);
        make.left.mas_equalTo(ws.keyImageView.mas_right).offset(kMargin10);
        make.right.mas_equalTo(ws.mas_right).offset(0);
        make.height.mas_equalTo(20);
    }];
    
    [self.valueLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.valueLab1.mas_bottom).offset(kMargin10);
        make.left.right.height.mas_equalTo(ws.valueLab1);
    }];
    
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(ws);
        make.bottom.mas_equalTo(ws.keyImageView).offset(0);
    }];
}

- (UILabel *)valueLab1 {
    if (!_valueLab1) {
        self.valueLab1 = [UILabel new];
        _valueLab1.textAlignment = NSTextAlignmentLeft;
        _valueLab1.font = kFontSize15;
        _valueLab1.textColor = RGBA(243, 161, 50, 1);
        _valueLab1.text = NSLocalizedString(@"华创客户管理系统", nil);
        _valueLab1.hidden = YES;
    }
    return _valueLab1;
}

- (UILabel *)valueLab2 {
    if (!_valueLab2) {
        self.valueLab2 = [UILabel new];
        _valueLab2.textAlignment = NSTextAlignmentLeft;
        _valueLab2.font = kFontSize15;
        _valueLab2.textColor = RGBA(243, 161, 50, 1);
        _valueLab2.text = @"Light CM System";
        _valueLab2.hidden = YES;
    }
    return _valueLab2;
}
- (UIImageView *)keyImageView {
    if (!_keyImageView) {
        self.keyImageView = [UIImageView new];
        _keyImageView.image = [UIImage imageNamed:@"logo"];
//        _keyImageView.backgroundColor = [UIColor orangeColor];
    }
    return _keyImageView;
}

@end
